﻿using BCCommon.TMS.FreightEnums;
using BCCommon.TMS.Order;
using BCCommon.TMS.Transport;
using BCEntity.MySql.FreightConfigurationExtention;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BCData.TMS.FreightConfigurationExtention
{
    /// <summary>
    /// 运费配置扩展--零担区间价格配置
    /// </summary>
    public interface IFreightConfigurationExtentionData
    {
        /// <summary>
        /// 检查运费配置扩展信息是否存在
        /// </summary>
        /// <param name="provinceCode">省份编码</param>
        /// <param name="cityCode">城市编码</param>
        /// <param name="countyCode">区县编码</param>
        /// <param name="firstWeight">开始重量</param>
        /// <param name="maxWeight">结束重量</param>
        /// <param name="startPrice">立方</param>
        /// <param name="everyWeightPrice">续重价格</param>
        /// <param name="transportMode">运输方式</param>
        /// <param name="sourceType">订单来源</param>
        /// <param name="freightType">物流类型</param>
        /// <param name="vehicleTypeId">车型Id</param>
        /// <param name="vehicleCategoryReferenceId">车辆分类Id</param>
        /// <returns></returns>
        Task<bool> CheckFreightConfigurationExtentionExists(string provinceCode, string cityCode, string countyCode, decimal firstWeight, decimal maxWeight, 
            decimal startPrice, decimal everyWeightPrice, OrderSourceType sourceType, FreightType freightType, int vehicleTypeId);

        /// <summary>
        /// 添加运费配置扩展
        /// </summary>
        /// <param name="entity">运费配置扩展信息</param>
        /// <returns></returns>
        Task<FreightConfigurationExtentionEntity> Add(FreightConfigurationExtentionEntity entity);

        /// <summary>
        /// 修改运费配置扩展
        /// </summary>
        /// <param name="freightConfigurationExtentionEntity">运费配置扩展信息</param>
        /// <returns></returns>
        Task<FreightConfigurationExtentionEntity> Update(FreightConfigurationExtentionEntity freightConfigurationExtentionEntity);

        /// <summary>
        /// 删除运费配置扩展信息
        /// </summary>
        /// <param name="freightConfigurationExtentionId">运费配置扩展Id</param>
        /// <returns></returns>
        Task<int> Delete(int freightConfigurationExtentionId);

        /// <summary>
        /// 通过运费配置id 查询
        /// </summary>
        /// <param name="freightConfigurationExtentionId">运费配置id</param>
        /// <returns></returns>
        Task<FreightConfigurationExtentionExpandEntity> GetById(int freightConfigurationExtentionId);

        /// <summary>
        /// 分页条件查询
        /// </summary>
        /// <param name="agentRecordId">代理商Id</param>
        /// <param name="viewEntity"></param>
        /// <returns></returns>
        Task<(IEnumerable<FreightConfigurationExtentionExpandEntity>, int)> GetAll(long? agentRecordId, FreightConfigurationExtentionViewEntity viewEntity);
        
        /// <summary>
        /// 获取已存在运费配置的区县编码
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<string>> GetCountyCodeList();

        /// <summary>
        /// 新增修复不存在运费配置的区县编码
        /// </summary>
        /// <param name="tempCountyCode">需要修复的区县编码</param>
        /// <param name="countyCode">已存在的运费配置的区县编码</param>
        /// <returns></returns>
        Task<int> InsertReparir(string tempCountyCode, string countyCode);

        /// <summary>
        /// 获取运费配置
        /// </summary>
        /// <param name="vehicleTypeId">车辆类型Id</param>
        /// <param name="provinceCode">省份Code</param>
        /// <param name="cityCode">市Code</param>
        /// <param name="countyCode">发货地县区Code</param>
        /// <param name="transportMode">运输方式</param>
        /// <param name="sourceType">订单来源</param>
        /// <param name="freightType">物流类型</param>
        /// <returns></returns>
        Task<FreightConfigurationExtentionExpandEntity> GetFreight(int? vehicleTypeId, string provinceCode, string cityCode, 
            string countyCode, OrderSourceType? sourceType, FreightType? freightType);
        /// <summary>
        /// 获取运费阶梯
        /// </summary>
        /// <param name="countyCode">区县编码</param>
        /// <param name="maxWeight">最大重量</param>
        /// <param name="orderSourceType">订单来源类型</param>
        /// <param name="freightType">运费类型</param>
        /// <returns></returns>
        Task<FreightConfigurationExtentionEntity> Get(string countyCode, decimal maxWeight, OrderSourceType orderSourceType, FreightType? freightType);
        /// <summary>
        /// 获取车型ID
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<int>> GetVehicleTypeIdList();

        /// <summary>
        /// 新增修复不存在运费配置的车型
        /// </summary>
        /// <param name="vehicleTypeId">已存在车型</param>
        /// <param name="tempVehicleTypeId">新增车型ID</param>
        /// <returns></returns>
        Task<int> InsertReparir(int vehicleTypeId, int tempVehicleTypeId);
    }
}